package cn.wolfcode.luowowo.controller;


import cn.wolfcode.luowowo.annotation.RequireLogin;
import cn.wolfcode.luowowo.domain.*;
import cn.wolfcode.luowowo.exception.LogicException;
import cn.wolfcode.luowowo.service.*;
import cn.wolfcode.luowowo.service.IDestinationService;
import cn.wolfcode.luowowo.util.JsonResult;
import cn.wolfcode.luowowo.vo.CatalogVO;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/destinations")
public class DestinationsController {
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IRegionService regionService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    
    @GetMapping("/hotRegion")
    public Object hotRegion(){
        List<Region> list = regionService.hotRegion();
        return JsonResult.success(list);
    }
    @GetMapping("/search")
    public Object search(String regionId){
        List<Destination> list = destinationService.search(regionId);
        return JsonResult.success(list);
    }
    @GetMapping("/toasts")
    public Object toasts(String destId){
        List<Destination> toasts = destinationService.getToasts(destId);
        return JsonResult.success(toasts);
    }
    @GetMapping("/detail")
    public Object detail(String id){
        Destination destination = destinationService.get(id);
        return JsonResult.success(destination);
    }
    @GetMapping("/catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> list = strategyCatalogService.catalogs(destId);
        return JsonResult.success(list);
    }
    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId){
        List<Strategy> list = strategyService.viewnumTop3(destId);
        return JsonResult.success(list);
    }
}
